home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / chaserog.zip / SRC_ROG.ZIP / WEAPONS.QC < prev    next >
Text File  |  1997-05-02  |  38KB  |  1,761 lines

  1. /*
  2. */
  3.  
  4. float lavaGunFired;
  5.  
  6. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  7. void () player_run;
  8. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  9. void(vector org, vector vel, float damage) SpawnBlood;
  10. void() SuperDamageSound;
  11.  
  12.  
  13. // called by worldspawn
  14. void() W_Precache =
  15. {
  16.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  17.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  18.     precache_sound ("weapons/sgun1.wav");
  19.     precache_sound ("weapons/guncock.wav");    // player shotgun
  20.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  21.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  22.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  23.     precache_sound ("weapons/spike2.wav");    // super spikes
  24.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  25.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  26.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  27.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  28.  
  29. //ZOID--
  30.     // grapple
  31.     precache_sound("weapons/chain1.wav");
  32. //    precache_sound("weapons/chain2.wav");
  33. //    precache_sound("weapons/chain3.wav");
  34. //    precache_sound("weapons/bounce2.wav");
  35. //    precache_sound("blob/land1.wav");
  36.     precache_sound("pendulum/hit.wav");
  37. //--ZOID
  38.  
  39.     precache_sound ("lavagun/snail.wav");        // lava nail gun cooldown
  40.  
  41.     // Rob; Bort's swinging hook
  42.     precache_sound ("shambler/smack.wav");
  43.     precache_sound ("blob/land1.wav");
  44.     precache_sound ("hook/chain1.wav");
  45.     precache_sound ("hook/chain2.wav");
  46.     precache_sound ("hook/retract.wav");
  47.  
  48. };
  49.  
  50. float() crandom =
  51. {
  52.     return 2*(random() - 0.5);
  53. };
  54.  
  55. /*
  56. ================
  57. W_FireAxe
  58. ================
  59. */
  60. void() W_FireAxe =
  61. {
  62.     local    vector    source;
  63.     local    vector    org;
  64.  
  65.     makevectors (self.v_angle);
  66.     source = self.origin + '0 0 16';
  67.     traceline (source, source + v_forward*64, FALSE, self);
  68.     if (trace_fraction == 1.0)
  69.         return;
  70.     
  71.     org = trace_endpos - v_forward*4;
  72.  
  73.     if (trace_ent.takedamage)
  74.     {
  75.         trace_ent.axhitme = 1;
  76.         SpawnBlood (org, '0 0 0', 20);
  77.         T_Damage (trace_ent, self, self, 20);
  78.     }
  79.     else
  80.     {    // hit wall
  81.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  82.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  83.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  84.         WriteCoord (MSG_BROADCAST, org_x);
  85.         WriteCoord (MSG_BROADCAST, org_y);
  86.         WriteCoord (MSG_BROADCAST, org_z);
  87.     }
  88. };
  89.  
  90.  
  91. //============================================================================
  92.  
  93.  
  94. vector() wall_velocity =
  95. {
  96.     local vector    vel;
  97.     
  98.     vel = normalize (self.velocity);
  99.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  100.     vel = vel + 2*trace_plane_normal;
  101.     vel = vel * 200;
  102.     
  103.     return vel;
  104. };
  105.  
  106.  
  107. /*
  108. ================
  109. SpawnMeatSpray
  110. ================
  111. */
  112. void(vector org, vector vel) SpawnMeatSpray =
  113. {
  114.     local    entity missile, mpuff;
  115.     local    vector    org;
  116.  
  117.     missile = spawn ();
  118.     missile.owner = self;
  119.     missile.movetype = MOVETYPE_BOUNCE;
  120.     missile.solid = SOLID_NOT;
  121.  
  122.     makevectors (self.angles);
  123.  
  124.     missile.velocity = vel;
  125.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  126.  
  127.     missile.avelocity = '3000 1000 2000';
  128.     
  129. // set missile duration
  130.     missile.nextthink = time + 1;
  131.     missile.think = SUB_Remove;
  132.  
  133.     setmodel (missile, "progs/zom_gib.mdl");
  134.     setsize (missile, '0 0 0', '0 0 0');        
  135.     setorigin (missile, org);
  136. };
  137.  
  138. /*
  139. ================
  140. SpawnBlood
  141. ================
  142. */
  143. void(vector org, vector vel, float damage) SpawnBlood =
  144. {
  145.     particle (org, vel*0.1, 73, damage*2);
  146. };
  147.  
  148. /*
  149. ================
  150. spawn_touchblood
  151. ================
  152. */
  153. void(float damage) spawn_touchblood =
  154. {
  155.     local vector    vel;
  156.  
  157.     vel = wall_velocity () * 0.2;
  158.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  159. };
  160.  
  161.  
  162. /*
  163. ================
  164. SpawnChunk
  165. ================
  166. */
  167. void(vector org, vector vel) SpawnChunk =
  168. {
  169.     particle (org, vel*0.02, 0, 10);
  170. };
  171.  
  172. /*
  173. ==============================================================================
  174.  
  175. MULTI-DAMAGE
  176.  
  177. Collects multiple small damages into a single damage
  178.  
  179. ==============================================================================
  180. */
  181.  
  182. entity    multi_ent;
  183. float    multi_damage;
  184.  
  185. void() ClearMultiDamage =
  186. {
  187.     multi_ent = world;
  188.     multi_damage = 0;
  189. };
  190.  
  191. void() ApplyMultiDamage =
  192. {
  193.     if (!multi_ent)
  194.         return;
  195.     T_Damage (multi_ent, self, self, multi_damage);
  196. };
  197.  
  198. void(entity hit, float damage) AddMultiDamage =
  199. {
  200.     if (!hit)
  201.         return;
  202.     
  203.     if (hit != multi_ent)
  204.     {
  205.         ApplyMultiDamage ();
  206.         multi_damage = damage;
  207.         multi_ent = hit;
  208.     }
  209.     else
  210.         multi_damage = multi_damage + damage;
  211. };
  212.  
  213. /*
  214. ==============================================================================
  215.  
  216. BULLETS
  217.  
  218. ==============================================================================
  219. */
  220.  
  221. /*
  222. ================
  223. TraceAttack
  224. ================
  225. */
  226. void(float damage, vector dir) TraceAttack =
  227. {
  228.     local    vector    vel, org;
  229.     
  230.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  231.     vel = vel + 2*trace_plane_normal;
  232.     vel = vel * 200;
  233.  
  234.     org = trace_endpos - dir*4;
  235.  
  236.     if (trace_ent.takedamage)
  237.     {
  238.         SpawnBlood (org, vel*0.2, damage);
  239.         AddMultiDamage (trace_ent, damage);
  240.     }
  241.     else
  242.     {
  243.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  244.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  245.         WriteCoord (MSG_BROADCAST, org_x);
  246.         WriteCoord (MSG_BROADCAST, org_y);
  247.         WriteCoord (MSG_BROADCAST, org_z);
  248.     }
  249. };
  250.  
  251. /*
  252. ================
  253. FireBullets
  254.  
  255. Used by shotgun, super shotgun, and enemy soldier firing
  256. Go to the trouble of combining multiple pellets into a single damage call.
  257. ================
  258. */
  259. void(float shotcount, vector dir, vector spread) FireBullets =
  260. {
  261.     local    vector direction;
  262.     local    vector    src;
  263.     
  264.     makevectors(self.v_angle);
  265.  
  266.     src = self.origin + v_forward*10;
  267.     src_z = self.absmin_z + self.size_z * 0.7;
  268.  
  269.     ClearMultiDamage ();
  270.     while (shotcount > 0)
  271.     {
  272.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  273.  
  274.         traceline (src, src + direction*2048, FALSE, self);
  275.         if (trace_fraction != 1.0)
  276.             TraceAttack (4, direction);
  277.  
  278.         shotcount = shotcount - 1;
  279.     }
  280.     ApplyMultiDamage ();
  281. };
  282.  
  283. /*
  284. ================
  285. W_FireShotgun
  286. ================
  287. */
  288. void() W_FireShotgun =
  289. {
  290.     local vector dir;
  291.  
  292.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  293.  
  294.     self.punchangle_x = -2;
  295.     
  296.     self.currentammo = self.ammo_shells1 = self.ammo_shells1 - 1;
  297.     UpdateAmmoCounts(self);
  298.     dir = aim (self, 100000);
  299.     FireBullets (6, dir, '0.04 0.04 0');
  300. };
  301.  
  302.  
  303. /*
  304. ================
  305. W_FireSuperShotgun
  306. ================
  307. */
  308. void() W_FireSuperShotgun =
  309. {
  310.     local vector dir;
  311.  
  312.     if (self.currentammo == 1)
  313.     {
  314.         W_FireShotgun ();
  315.         return;
  316.     }
  317.         
  318.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  319.  
  320.     self.punchangle_x = -4;
  321.     
  322.     self.currentammo = self.ammo_shells1 = self.ammo_shells1 - 2;
  323.     UpdateAmmoCounts(self);
  324.     dir = aim (self, 100000);
  325.     FireBullets (14, dir, '0.14 0.08 0');
  326. };
  327.  
  328.  
  329. /*
  330. ==============================================================================
  331.  
  332. ROCKETS
  333.  
  334. ==============================================================================
  335. */
  336.  
  337. void()    s_explode1    =    [0,        s_explode2] {};
  338. void()    s_explode2    =    [1,        s_explode3] {};
  339. void()    s_explode3    =    [2,        s_explode4] {};
  340. void()    s_explode4    =    [3,        s_explode5] {};
  341. void()    s_explode5    =    [4,        s_explode6] {};
  342. void()    s_explode6    =    [5,        SUB_Remove] {};
  343.  
  344. void() BecomeExplosion =
  345. {
  346.     self.movetype = MOVETYPE_NONE;
  347.     self.velocity = '0 0 0';
  348.     self.touch = SUB_Null;
  349.     setmodel (self, "progs/s_explod.spr");
  350.     self.solid = SOLID_NOT;
  351.     s_explode1 ();
  352. };
  353.  
  354. void() T_MissileTouch =
  355. {
  356.     local float    damg;
  357.  
  358.     if (other == self.owner)
  359.         return;        // don't explode on owner
  360.  
  361.     if (pointcontents(self.origin) == CONTENT_SKY)
  362.     {
  363.         remove(self);
  364.         return;
  365.     }
  366.  
  367.     damg = 100 + random()*20;
  368.     
  369.     if (other.health)
  370.     {
  371.         if (other.classname == "monster_shambler")
  372.             damg = damg * 0.5;    // mostly immune
  373.         T_Damage (other, self, self.owner, damg );
  374.     }
  375.  
  376.     // don't do radius damage to the other, because all the damage
  377.     // was done in the impact
  378.     T_RadiusDamage (self, self.owner, 120, other);
  379.  
  380. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  381.     self.origin = self.origin - 8*normalize(self.velocity);
  382.  
  383.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  384.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  385.     WriteCoord (MSG_BROADCAST, self.origin_x);
  386.     WriteCoord (MSG_BROADCAST, self.origin_y);
  387.     WriteCoord (MSG_BROADCAST, self.origin_z);
  388.  
  389.     BecomeExplosion ();
  390. };
  391.  
  392.  
  393.  
  394. /*
  395. ================
  396. W_FireRocket
  397. ================
  398. */
  399. void() W_FireRocket =
  400. {
  401.     local    entity missile, mpuff;
  402.     
  403.     self.currentammo = self.ammo_rockets1 = self.ammo_rockets1 - 1;
  404.     UpdateAmmoCounts(self);
  405.     
  406.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  407.  
  408.     self.punchangle_x = -2;
  409.  
  410.     missile = spawn ();
  411.     missile.owner = self;
  412.     missile.movetype = MOVETYPE_FLYMISSILE;
  413.     missile.solid = SOLID_BBOX;
  414.     missile.classname = "missile";
  415.     
  416. // set missile speed    
  417.  
  418.     makevectors (self.v_angle);
  419.     missile.velocity = aim(self, 1000);
  420.     missile.velocity = missile.velocity * 1000;
  421.     missile.angles = vectoangles(missile.velocity);
  422.     
  423.     missile.touch = T_MissileTouch;
  424.     
  425. // set missile duration
  426.     missile.nextthink = time + 5;
  427.     missile.think = SUB_Remove;
  428.  
  429.     setmodel (missile, "progs/missile.mdl");
  430.     setsize (missile, '0 0 0', '0 0 0');        
  431.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  432. };
  433.  
  434. /*
  435. ===============================================================================
  436.  
  437. LIGHTNING
  438.  
  439. ===============================================================================
  440. */
  441.  
  442. /*
  443. =================
  444. LightningDamage
  445. =================
  446. */
  447. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  448. {
  449.     local entity        e1, e2;
  450.     local vector        f;
  451.     
  452.     f = p2 - p1;
  453.     normalize (f);
  454.     f_x = 0 - f_y;
  455.     f_y = f_x;
  456.     f_z = 0;
  457.     f = f*16;
  458.  
  459.     e1 = e2 = world;
  460.  
  461.     traceline (p1, p2, FALSE, self);
  462.     if (trace_ent.takedamage)
  463.     {
  464.         particle (trace_endpos, '0 0 100', 225, damage*4);
  465.         T_Damage (trace_ent, from, from, damage);
  466.         if (self.classname == "player")
  467.         {
  468.             if (other.classname == "player")
  469.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  470.         }
  471.     }
  472.     e1 = trace_ent;
  473.  
  474.     traceline (p1 + f, p2 + f, FALSE, self);
  475.     if (trace_ent != e1 && trace_ent.takedamage)
  476.     {
  477.         particle (trace_endpos, '0 0 100', 225, damage*4);
  478.         T_Damage (trace_ent, from, from, damage);
  479.     }
  480.     e2 = trace_ent;
  481.  
  482.     traceline (p1 - f, p2 - f, FALSE, self);
  483.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  484.     {
  485.         particle (trace_endpos, '0 0 100', 225, damage*4);
  486.         T_Damage (trace_ent, from, from, damage);
  487.     }
  488. };
  489.  
  490.  
  491. void() W_FireLightning =
  492. {
  493.     local    vector        org;
  494.     local    float        cells;
  495.  
  496.     if (self.ammo_cells1 < 1)
  497.     {
  498.         self.weapon = W_BestWeapon ();
  499.         W_SetCurrentAmmo ();
  500.         return;
  501.     }
  502.  
  503. // explode if under water
  504.     if (self.waterlevel > 1)
  505.     {
  506.         cells = self.ammo_cells1;
  507.         self.ammo_cells1 = 0;
  508.         W_SetCurrentAmmo ();
  509.         T_RadiusDamage (self, self, 35*cells, world);
  510.         return;
  511.     }
  512.  
  513.     if (self.t_width < time)
  514.     {
  515.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  516.         self.t_width = time + 0.6;
  517.     }
  518.     self.punchangle_x = -2;
  519.  
  520.     self.currentammo = self.ammo_cells1 = self.ammo_cells1 - 1;
  521.     UpdateAmmoCounts(self);
  522.  
  523.     org = self.origin + '0 0 16';
  524.     
  525.     makevectors (self.v_angle);
  526.     traceline (org, org + v_forward*600, TRUE, self);
  527.  
  528.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  529.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  530.     WriteEntity (MSG_BROADCAST, self);
  531.     WriteCoord (MSG_BROADCAST, org_x);
  532.     WriteCoord (MSG_BROADCAST, org_y);
  533.     WriteCoord (MSG_BROADCAST, org_z);
  534.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  535.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  536.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  537.  
  538.     LightningDamage (self.origin + '0 0 16', trace_endpos + v_forward*4, self, 30);
  539. };
  540.  
  541.  
  542. //=============================================================================
  543.  
  544.  
  545. void() GrenadeExplode =
  546. {
  547.     T_RadiusDamage (self, self.owner, 120, world);
  548.  
  549.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  550.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  551.     WriteCoord (MSG_BROADCAST, self.origin_x);
  552.     WriteCoord (MSG_BROADCAST, self.origin_y);
  553.     WriteCoord (MSG_BROADCAST, self.origin_z);
  554.  
  555.     BecomeExplosion ();
  556. };
  557.  
  558. void() GrenadeTouch =
  559. {
  560.     if (other == self.owner)
  561.         return;        // don't explode on owner
  562.  
  563.     if (other.takedamage == DAMAGE_AIM)
  564.     {
  565.         GrenadeExplode();
  566.         return;
  567.     }
  568.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  569.     if (self.velocity == '0 0 0')
  570.         self.avelocity = '0 0 0';
  571. };
  572.  
  573. /*
  574. ================
  575. W_FireGrenade
  576. ================
  577. */
  578. void() W_FireGrenade =
  579. {
  580.     local    entity missile, mpuff;
  581.     
  582.     self.currentammo = self.ammo_rockets1 = self.ammo_rockets1 - 1;
  583.     UpdateAmmoCounts(self);
  584.     
  585.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  586.  
  587.     self.punchangle_x = -2;
  588.  
  589.     missile = spawn ();
  590.     missile.owner = self;
  591.     missile.movetype = MOVETYPE_BOUNCE;
  592.     missile.solid = SOLID_BBOX;
  593.     missile.classname = "grenade";
  594.         
  595. // set missile speed    
  596.  
  597.     makevectors (self.v_angle);
  598.  
  599.     if (self.v_angle_x)
  600.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  601.     else
  602.     {
  603.         missile.velocity = aim(self, 10000);
  604.         missile.velocity = missile.velocity * 600;
  605.         missile.velocity_z = 200;
  606.     }
  607.  
  608.     missile.avelocity = '300 300 300';
  609.  
  610.     missile.angles = vectoangles(missile.velocity);
  611.     
  612.     missile.touch = GrenadeTouch;
  613.     
  614. // set missile duration
  615.     missile.nextthink = time + 2.5;
  616.     missile.think = GrenadeExplode;
  617.  
  618.     setmodel (missile, "progs/grenade.mdl");
  619.     setsize (missile, '0 0 0', '0 0 0');        
  620.     setorigin (missile, self.origin);
  621. };
  622.  
  623.  
  624. //=============================================================================
  625.  
  626. void() spike_touch;
  627. void() superspike_touch;
  628. void() lavaspike_touch;
  629. void() superlavaspike_touch;
  630.  
  631. /*
  632. ===============
  633. launch_spike
  634.  
  635. Used for both the player and the ogre
  636. ===============
  637. */
  638. void(vector org, vector dir) launch_spike =
  639. {
  640.     newmis = spawn ();
  641.     newmis.owner = self;
  642.     newmis.movetype = MOVETYPE_FLYMISSILE;
  643.     newmis.solid = SOLID_BBOX;
  644.  
  645.     newmis.angles = vectoangles(dir);
  646.     
  647.     newmis.touch = spike_touch;
  648.     newmis.classname = "spike";
  649.     newmis.think = SUB_Remove;
  650.     newmis.nextthink = time + 6;
  651.     setmodel (newmis, "progs/spike.mdl");
  652.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  653.     setorigin (newmis, org);
  654.  
  655.     newmis.velocity = dir * 1000;
  656. };
  657.  
  658. void() W_FireSuperSpikes =
  659. {
  660.     local vector    dir;
  661.     local entity    old;
  662.     
  663.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  664.     self.attack_finished = time + 0.2;
  665.  
  666.     self.currentammo = self.ammo_nails1 = self.ammo_nails1 - 2;
  667.     UpdateAmmoCounts(self);
  668.  
  669.     dir = aim (self, 1000);
  670.     launch_spike (self.origin + '0 0 16', dir);
  671.     newmis.touch = superspike_touch;
  672.     setmodel (newmis, "progs/s_spike.mdl");
  673.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);            
  674.     self.punchangle_x = -2;
  675. };
  676.  
  677. void(float ox) W_FireSpikes =
  678. {
  679.     local vector    dir;
  680.     local entity    old;
  681.     
  682.     makevectors (self.v_angle);
  683.     
  684.     if (self.ammo_nails1 >= 2 && self.weapon == IT_SUPER_NAILGUN)
  685.     {
  686.         W_FireSuperSpikes ();
  687.         return;
  688.     }
  689.  
  690.     if (self.ammo_nails1 < 1)
  691.     {
  692.         self.weapon = W_BestWeapon ();
  693.         W_SetCurrentAmmo ();
  694.         return;
  695.     }
  696.  
  697.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  698.     self.attack_finished = time + 0.2;
  699.     self.currentammo = self.ammo_nails1 = self.ammo_nails1 - 1;
  700.     UpdateAmmoCounts(self);
  701.  
  702.     dir = aim (self, 1000);
  703.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  704.  
  705.     self.punchangle_x = -2;
  706. };
  707.  
  708. .float hit_z;
  709. void() spike_touch =
  710. {
  711. local float rand;
  712.     if (other == self.owner)
  713.         return;
  714.  
  715.     if (other.solid == SOLID_TRIGGER)
  716.         return;    // trigger field, do nothing
  717.  
  718.     if (pointcontents(self.origin) == CONTENT_SKY)
  719.     {
  720.         remove(self);
  721.         return;
  722.     }
  723.     
  724. // hit something that bleeds
  725.     if (other.takedamage)
  726.     {
  727.         spawn_touchblood (9);
  728.         T_Damage (other, self, self.owner, 9);
  729.     }
  730.     else
  731.     {
  732.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  733.         
  734.         if (self.classname == "wizspike")
  735.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  736.         else if (self.classname == "knightspike")
  737.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  738.         else
  739.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  740.         WriteCoord (MSG_BROADCAST, self.origin_x);
  741.         WriteCoord (MSG_BROADCAST, self.origin_y);
  742.         WriteCoord (MSG_BROADCAST, self.origin_z);
  743.     }
  744.  
  745.     remove(self);
  746.  
  747. };
  748.  
  749. void() superspike_touch =
  750. {
  751. local float rand;
  752.     if (other == self.owner)
  753.         return;
  754.  
  755.     if (other.solid == SOLID_TRIGGER)
  756.         return;    // trigger field, do nothing
  757.  
  758.     if (pointcontents(self.origin) == CONTENT_SKY)
  759.     {
  760.         remove(self);
  761.         return;
  762.     }
  763.     
  764. // hit something that bleeds
  765.     if (other.takedamage)
  766.     {
  767.         spawn_touchblood (18);
  768.         T_Damage (other, self, self.owner, 18);
  769.     }
  770.     else
  771.     {
  772.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  773.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  774.         WriteCoord (MSG_BROADCAST, self.origin_x);
  775.         WriteCoord (MSG_BROADCAST, self.origin_y);
  776.         WriteCoord (MSG_BROADCAST, self.origin_z);
  777.     }
  778.  
  779.     remove(self);
  780.  
  781. };
  782.  
  783. /*
  784. ===============================================================================
  785.  
  786. PLAYER WEAPON USE
  787.  
  788. ===============================================================================
  789. */
  790.  
  791. void() W_SetCurrentAmmo =
  792. {
  793.     player_run ();        // get out of any weapon firing states
  794.  
  795.     self.items = self.items - 
  796.         ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS));
  797.     self.items2 = self.items2 - 
  798.         (self.items2 & (IT2_LAVA_NAILS|IT2_PLASMA_AMMO|IT2_MULTI_ROCKETS));
  799.     
  800.     if (self.weapon == IT_AXE)
  801.     {
  802.         self.currentammo = 0;
  803.         self.weaponmodel = "progs/v_axe.mdl";
  804.         self.weaponframe = 0;
  805.     }
  806. //ZOID--
  807.     else if (self.weapon == IT_GRAPPLE)
  808.     {
  809.         self.currentammo = 0;
  810.         self.weaponmodel = "progs/v_grpple.mdl";
  811.         self.weaponframe = 0;
  812.     }
  813. //--ZOID
  814.     else if (self.weapon == IT_SHOTGUN)
  815.     {
  816.         self.currentammo = self.ammo_shells1;
  817.         self.weaponmodel = "progs/v_shot.mdl";
  818.         self.weaponframe = 0;
  819.         self.items = self.items | IT_SHELLS;
  820.     }
  821.     else if (self.weapon == IT_SUPER_SHOTGUN)
  822.     {
  823.         self.currentammo = self.ammo_shells1;
  824.         self.weaponmodel = "progs/v_shot2.mdl";
  825.         self.weaponframe = 0;
  826.         self.items = self.items | IT_SHELLS;
  827.     }
  828.     else if (self.weapon == IT_LAVA_NAILGUN)
  829.     {
  830.         self.currentammo = self.ammo_lava_nails;
  831.         self.weaponmodel = "progs/v_lava.mdl";
  832.         self.weaponframe = 0;
  833.         self.items2 = self.items2 | IT2_LAVA_NAILS;
  834.     }
  835.     else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  836.     {
  837.         self.currentammo = self.ammo_lava_nails;
  838.         self.weaponmodel = "progs/v_lava2.mdl";
  839.         self.weaponframe = 0;
  840.         self.items2 = self.items2 | IT2_LAVA_NAILS;
  841.     }
  842.     else if (self.weapon == IT_MULTI_GRENADE)
  843.     {
  844.         self.currentammo = self.ammo_multi_rockets;
  845.         self.weaponmodel = "progs/v_multi.mdl";
  846.         self.weaponframe = 0;
  847.         self.items2 = self.items2 | IT2_MULTI_ROCKETS;
  848.     }
  849.     else if (self.weapon == IT_MULTI_ROCKET)
  850.     {            
  851.         self.currentammo = self.ammo_multi_rockets;
  852.         self.weaponmodel = "progs/v_multi2.mdl";
  853.         self.weaponframe = 0;
  854.         self.items2 = self.items2 | IT2_MULTI_ROCKETS;
  855.     }
  856.     else if (self.weapon == IT_PLASMA_GUN)
  857.     {
  858.         self.currentammo = self.ammo_plasma;
  859.         self.weaponmodel = "progs/v_plasma.mdl";
  860.         self.weaponframe = 0;
  861.         self.items2 = self.items2 | IT2_PLASMA_AMMO;
  862.     }
  863.     else if (self.weapon == IT_NAILGUN)
  864.     {
  865.         self.currentammo = self.ammo_nails1;
  866.         self.weaponmodel = "progs/v_nail.mdl";
  867.         self.weaponframe = 0;
  868.         self.items = self.items | IT_NAILS;
  869.     }
  870.     else if (self.weapon == IT_SUPER_NAILGUN)
  871.     {
  872.         self.currentammo = self.ammo_nails1;
  873.         self.weaponmodel = "progs/v_nail2.mdl";
  874.         self.weaponframe = 0;
  875.         self.items = self.items | IT_NAILS;
  876.     }
  877.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  878.     {
  879.         self.currentammo = self.ammo_rockets1;
  880.         self.weaponmodel = "progs/v_rock.mdl";
  881.         self.weaponframe = 0;
  882.         self.items = self.items | IT_ROCKETS;
  883.     }
  884.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  885.     {
  886.         self.currentammo = self.ammo_rockets1;
  887.         self.weaponmodel = "progs/v_rock2.mdl";
  888.         self.weaponframe = 0;
  889.         self.items = self.items | IT_ROCKETS;
  890.     }
  891.     else if (self.weapon == IT_LIGHTNING)
  892.     {
  893.         self.currentammo = self.ammo_cells1;
  894.         self.weaponmodel = "progs/v_light.mdl";
  895.         self.weaponframe = 0;
  896.         self.items = self.items | IT_CELLS;
  897.     }
  898.     else
  899.     {
  900.         self.currentammo = 0;
  901.         self.weaponmodel = "";
  902.         self.weaponframe = 0;
  903.     }
  904.     UpdateAmmoCounts(self);
  905.  
  906.     // ### chasecam mod ###
  907.     // disable model in chase view
  908.     if ( (self.dest2_x & CHSCAM_ON) )
  909.     {
  910.         self.weaponmodel = "";
  911.         HUD_print_info(1);
  912.     }
  913.  
  914. };
  915.  
  916. float() W_BestWeapon =
  917. {
  918.     local    float    it;
  919.  
  920.     it = self.items;
  921.  
  922. // pgm - fix for sandy. will not change to plasma gun
  923.     
  924. //    if(self.waterlevel <= 1 && self.ammo_plasma >= 1 && (it & IT_PLASMA_GUN))
  925. //        return IT_PLASMA_GUN;
  926. //    else 
  927.     if(self.waterlevel<=1 && self.ammo_cells1>=1 && (it & IT_LIGHTNING))
  928.         return IT_LIGHTNING;
  929.     else if(self.ammo_lava_nails >= 2 && (it & IT_LAVA_SUPER_NAILGUN) )
  930.         return IT_LAVA_SUPER_NAILGUN;
  931.     else if(self.ammo_nails1 >= 2 && (it & IT_SUPER_NAILGUN) )
  932.         return IT_SUPER_NAILGUN;
  933.     else if(self.ammo_lava_nails >= 1 && (it & IT_LAVA_NAILGUN) )
  934.         return IT_LAVA_NAILGUN;
  935.     else if(self.ammo_nails1 >= 1 && (it & IT_NAILGUN) )
  936.         return IT_NAILGUN;
  937.     else if(self.ammo_shells1 >= 2 && (it & IT_SUPER_SHOTGUN) )
  938.         return IT_SUPER_SHOTGUN;
  939.     else if(self.ammo_shells1 >= 1 && (it & IT_SHOTGUN) )
  940.         return IT_SHOTGUN;
  941.         
  942.     return IT_AXE;
  943. };
  944.  
  945. float() W_CheckNoAmmo =
  946. {
  947.     if (self.currentammo > 0)
  948.         return TRUE;
  949.  
  950. //ZOID--
  951.     if (self.weapon == IT_AXE || self.weapon == IT_GRAPPLE)
  952.         return TRUE;
  953. //--ZOID
  954.     
  955.     self.weapon = W_BestWeapon ();
  956.  
  957.     W_SetCurrentAmmo ();
  958.     
  959. // drop the weapon down
  960.     return FALSE;
  961. };
  962.  
  963. /*
  964. ============
  965. W_Attack
  966.  
  967. An attack impulse can be triggered now
  968. ============
  969. */
  970. void()    player_axe1;
  971. void()    player_axeb1;
  972. void()    player_axec1;
  973. void()    player_axed1;
  974. void()    player_shot1;
  975. void()    player_nail1;
  976. void()    player_light1;
  977. void()    player_rocket1;
  978. void()    player_lava_nail1;
  979. //ZOID--
  980. void()  player_grapple1;
  981. void()  player_grapple3;
  982. //--ZOID
  983.  
  984. void() W_FireMultiGrenade;
  985. void() W_FireMultiRocket;
  986.  
  987. void() W_Attack =
  988. {
  989.     local    float    r;
  990.  
  991.     if (!W_CheckNoAmmo ())
  992.         return;
  993.  
  994.     makevectors    (self.v_angle);        // calculate forward angle for velocity
  995.     self.show_hostile = time + 1;    // wake monsters up
  996.  
  997. // ZOID--
  998.     RuneApplyBlackNoise(self); // make rune noise
  999. //--ZOID
  1000.  
  1001.     if (self.weapon == IT_AXE)
  1002.     {
  1003.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  1004.         r = random();
  1005.         if (r < 0.25)
  1006.             player_axe1 ();
  1007.         else if (r<0.5)
  1008.             player_axeb1 ();
  1009.         else if (r<0.75)
  1010.             player_axec1 ();
  1011.         else
  1012.             player_axed1 ();
  1013.         self.attack_finished = time + RuneApplyHell(0.5, self);
  1014.     }
  1015. //ZOID--
  1016.     else if (self.weapon == IT_GRAPPLE)
  1017.     {
  1018.         if (!self.hook_out)
  1019.             player_grapple1();
  1020.         else
  1021.             player_grapple3();
  1022.         self.attack_finished = time + 0.1;
  1023.     }
  1024. //--ZOID
  1025.     else if (self.weapon == IT_SHOTGUN)
  1026.     {
  1027.         player_shot1 ();
  1028.         W_FireShotgun ();
  1029.         self.attack_finished = time + RuneApplyHell(0.5, self);
  1030.     }
  1031.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1032.     {
  1033.         player_shot1 ();
  1034.         W_FireSuperShotgun ();
  1035.         self.attack_finished = time + RuneApplyHell(0.7, self);
  1036.     }
  1037.     else if (self.weapon == IT_LAVA_NAILGUN)
  1038.     {
  1039.         lavaGunFired = 1;
  1040.         player_lava_nail1 ();
  1041.     }
  1042.     else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1043.     {
  1044.         lavaGunFired = 1;
  1045.         player_lava_nail1 ();
  1046.     }
  1047.     else if (self.weapon == IT_MULTI_GRENADE)
  1048.     {
  1049.         player_rocket1();
  1050.         W_FireMultiGrenade();
  1051.         self.attack_finished = time + RuneApplyHell(0.6, self);
  1052.     }
  1053.     else if (self.weapon == IT_MULTI_ROCKET)
  1054.     {
  1055.         player_rocket1();
  1056.         W_FireMultiRocket();
  1057.         self.attack_finished = time + RuneApplyHell(0.8, self);
  1058.     }
  1059.     else if (self.weapon == IT_PLASMA_GUN)
  1060.     {
  1061.         // player_light1 determines choice of W_FireLightning 
  1062.         //    or W_FirePlasma, but same lighting and frames...
  1063.         self.attack_finished = time + RuneApplyHell(1.0, self);
  1064.         player_light1 ();
  1065.     }
  1066.     else if (self.weapon == IT_NAILGUN)
  1067.     {
  1068.         player_nail1 ();
  1069.     }
  1070.     else if (self.weapon == IT_SUPER_NAILGUN)
  1071.     {
  1072.         player_nail1 ();
  1073.     }
  1074.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1075.     {
  1076.         player_rocket1();
  1077.         W_FireGrenade();
  1078.         self.attack_finished = time + RuneApplyHell(0.6, self);
  1079.     }
  1080.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1081.     {
  1082.         player_rocket1();
  1083.         W_FireRocket();
  1084.         self.attack_finished = time + RuneApplyHell(0.8, self);
  1085.     }
  1086.     else if (self.weapon == IT_LIGHTNING)
  1087.     {
  1088.         player_light1();
  1089.         self.attack_finished = time + 0.1;
  1090.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1091.     }
  1092. };
  1093.  
  1094. /*
  1095. ============
  1096. W_ChangeWeapon
  1097.  
  1098. ============
  1099. */
  1100. void() W_ChangeWeapon =
  1101. {
  1102.     local    float    it, am, fl; 
  1103.         
  1104.     EnableComboWeapons ( self );
  1105.     UpdateAmmoCounts ( self );
  1106.  
  1107.     it = self.items;
  1108.     am = 0;
  1109.     
  1110.     if (self.impulse == 1)
  1111.     {
  1112. //ZOID--
  1113.         if (self.weapon == IT_AXE && deathmatch && teamplay >= TEAM_CTF)
  1114.             fl = IT_GRAPPLE;
  1115.         else
  1116.             fl = IT_AXE;
  1117.     }
  1118.     else if (self.impulse == 22)
  1119.     {
  1120.         if(deathmatch && teamplay >= TEAM_CTF)        //pgm optimization
  1121.             fl = IT_GRAPPLE;
  1122.     }
  1123. //--ZOID
  1124.     else if (self.impulse == 2)
  1125.     {
  1126.         fl = IT_SHOTGUN;
  1127.         if (self.ammo_shells1 < 1)
  1128.             am = 1;
  1129.     }
  1130.     else if (self.impulse == 3)
  1131.     {
  1132.         fl = IT_SUPER_SHOTGUN;
  1133.         if (self.ammo_shells1 < 2)
  1134.             am = 1;
  1135.     }    
  1136.     else if (self.impulse == 4)
  1137.     {
  1138.         if ((self.items & IT_LAVA_NAILGUN) && 
  1139.                 (self.weapon == IT_NAILGUN || self.ammo_nails1 < 1))
  1140.         {
  1141.             fl = IT_LAVA_NAILGUN;
  1142.             if (self.ammo_lava_nails < 1)
  1143.                 am = 1;
  1144.         }
  1145.         else
  1146.         {
  1147.             fl = IT_NAILGUN;
  1148.             if (self.ammo_nails1 < 1)
  1149.                 am = 1;
  1150.         }
  1151.     }
  1152.     else if (self.impulse == 5)
  1153.     {
  1154.         if ((self.items & IT_LAVA_SUPER_NAILGUN) && 
  1155.                 (self.weapon == IT_SUPER_NAILGUN || self.ammo_nails1 < 2))
  1156.         {
  1157.             fl = IT_LAVA_SUPER_NAILGUN;
  1158.             if (self.ammo_lava_nails < 2)
  1159.                 am = 1;
  1160.         }
  1161.         else
  1162.         {
  1163.             fl = IT_SUPER_NAILGUN;
  1164.             if (self.ammo_nails1 < 2)
  1165.                 am = 1;
  1166.         }
  1167.     }
  1168.     else if (self.impulse == 6)
  1169.     {
  1170.         if ((self.items & IT_MULTI_GRENADE) && 
  1171.                 (self.weapon == IT_GRENADE_LAUNCHER || self.ammo_rockets1 < 1))
  1172.         {
  1173.             fl = IT_MULTI_GRENADE;
  1174.             if (self.ammo_multi_rockets < 1)
  1175.                 am = 1;
  1176.         }
  1177.         else
  1178.         {
  1179.             fl = IT_GRENADE_LAUNCHER;
  1180.             if (self.ammo_rockets1 < 1)
  1181.                 am = 1;
  1182.         }
  1183.     }
  1184.     else if (self.impulse == 7)
  1185.     {
  1186.         if ((self.items & IT_MULTI_ROCKET) && 
  1187.             (self.weapon == IT_ROCKET_LAUNCHER || self.ammo_rockets1 < 1))
  1188.         {
  1189.             fl = IT_MULTI_ROCKET;
  1190.             if (self.ammo_multi_rockets < 1)
  1191.                 am = 1;
  1192.         }
  1193.         else
  1194.         {
  1195.             fl = IT_ROCKET_LAUNCHER;
  1196.             if (self.ammo_rockets1 < 1)
  1197.                 am = 1;
  1198.         }
  1199.     }
  1200.     else if (self.impulse == 8)
  1201.     {
  1202.         if ((self.items & IT_PLASMA_GUN) && 
  1203.                 (self.weapon == IT_LIGHTNING || self.ammo_cells1 < 1))
  1204.         {
  1205.             fl = IT_PLASMA_GUN;
  1206.             if (self.ammo_plasma < 1)
  1207.                 am = 1;
  1208.         }
  1209.         else
  1210.         {
  1211.             fl = IT_LIGHTNING;
  1212.             if (self.ammo_cells1 < 1)
  1213.                 am = 1;
  1214.         }
  1215.     }
  1216.     else if (self.impulse == 60)
  1217.     {
  1218.         fl = IT_LAVA_NAILGUN;
  1219.         if (self.ammo_lava_nails < 1)
  1220.             am = 1;
  1221.     }
  1222.     else if (self.impulse == 61)
  1223.     {
  1224.         fl = IT_LAVA_SUPER_NAILGUN;
  1225.         if (self.ammo_lava_nails < 1)
  1226.             am = 1;
  1227.     }
  1228.     else if (self.impulse == 62)
  1229.     {
  1230.         fl = IT_MULTI_GRENADE;
  1231.         if (self.ammo_multi_rockets < 1)
  1232.             am = 1;
  1233.     }
  1234.     else if (self.impulse == 63)
  1235.     {
  1236.         fl = IT_MULTI_ROCKET;
  1237.         if (self.ammo_multi_rockets < 1)
  1238.             am = 1;
  1239.     }
  1240.     else if (self.impulse == 64)
  1241.     {
  1242.         fl = IT_PLASMA_GUN;
  1243.         if (self.ammo_plasma < 1)
  1244.             am = 1;
  1245.     }
  1246.  
  1247.     self.impulse = 0;
  1248.     
  1249.     if (!(self.items & fl))
  1250.     {    // don't have the weapon or the ammo
  1251.         sprint (self, "no weapon.\n");
  1252.         return;
  1253.     }
  1254.  
  1255.     if (am)
  1256.     {    // don't have the ammo
  1257.         sprint (self, "not enough ammo.\n");
  1258.         return;
  1259.     }
  1260.     
  1261.     if (self.weapon != fl)
  1262.     {
  1263.         if (self.weapon == IT_LAVA_NAILGUN || 
  1264.                 self.weapon == IT_LAVA_SUPER_NAILGUN)
  1265.         {
  1266.             if (fl == IT_NAILGUN || fl == IT_SUPER_NAILGUN)
  1267.                 sprint (self, "Normal Nails\n");
  1268.         }
  1269.         else if (self.weapon == IT_MULTI_GRENADE)
  1270.         {
  1271.             if (fl == IT_GRENADE_LAUNCHER)
  1272.                 sprint (self, "Normal Grenades\n");
  1273.         }
  1274.         else if (self.weapon == IT_MULTI_ROCKET)
  1275.         {
  1276.             if (fl == IT_ROCKET_LAUNCHER)
  1277.                 sprint (self, "Normal Rockets\n");
  1278.         }
  1279.         else if (self.weapon == IT_PLASMA_GUN)
  1280.         {
  1281.             if (fl == IT_LIGHTNING)
  1282.                 sprint (self, "Lightning Gun\n");
  1283.         }
  1284.         else if (fl == IT_LAVA_NAILGUN || fl == IT_LAVA_SUPER_NAILGUN)
  1285.         {
  1286.             sprint (self, "Lava Nails!\n");
  1287.         }
  1288.         else if(fl == IT_MULTI_GRENADE)
  1289.         {
  1290.             sprint (self, "Multi-Grenades!\n");
  1291.         }
  1292.         else if(fl == IT_MULTI_ROCKET)
  1293.         {
  1294.             sprint (self, "Multi-Rockets!\n");
  1295.         }
  1296.         else if(fl == IT_PLASMA_GUN)
  1297.         {
  1298.             sprint (self, "Plasma Gun!\n");
  1299.         }
  1300.     }
  1301.     
  1302. //
  1303. // set weapon, set ammo
  1304. //    
  1305.     self.weapon = fl;
  1306.     W_SetCurrentAmmo ();
  1307. };
  1308.  
  1309. /*
  1310. ============
  1311. CheatCommand
  1312. ============
  1313. */
  1314. void() CheatCommand =
  1315. {
  1316.     if (deathmatch || coop)
  1317.         return;
  1318.  
  1319.     self.ammo_rockets1 = 100;
  1320.     self.ammo_nails1 = 200;
  1321.     self.ammo_shells1 = 100;
  1322.     
  1323.     self.items = self.items | 
  1324.         IT_AXE |
  1325.         IT_SHOTGUN |
  1326.         IT_SUPER_SHOTGUN |
  1327.         IT_NAILGUN |
  1328.         IT_SUPER_NAILGUN |
  1329.         IT_GRENADE_LAUNCHER |
  1330.         IT_ROCKET_LAUNCHER |
  1331.         IT_LAVA_NAILGUN | 
  1332.         IT_LAVA_SUPER_NAILGUN | 
  1333.         IT_MULTI_GRENADE |
  1334.         IT_MULTI_ROCKET | 
  1335.         IT_PLASMA_GUN | 
  1336.         IT_LIGHTNING;
  1337.             
  1338.     self.items = self.items | IT_KEY1 | IT_KEY2;
  1339.  
  1340.     self.ammo_lava_nails = 200;
  1341.     self.ammo_multi_rockets = 100;
  1342.     self.ammo_plasma = 100;
  1343.     self.ammo_cells1 = 200;
  1344.  
  1345.     self.weapon = IT_ROCKET_LAUNCHER;
  1346.     self.impulse = 0;
  1347.     W_SetCurrentAmmo ();
  1348. };
  1349.  
  1350. /*
  1351. ============
  1352. CycleWeaponCommand
  1353.  
  1354. Go to the next weapon with ammo
  1355. ============
  1356. */
  1357. void() CycleWeaponCommand =
  1358. {
  1359.     local    float    it, am;
  1360.     
  1361.     EnableComboWeapons ( self );
  1362.     UpdateAmmoCounts ( self );
  1363.  
  1364.     it = self.items;
  1365.     self.impulse = 0;
  1366.  
  1367.     while (1)
  1368.     {
  1369.         am = 0;
  1370.  
  1371.         if (self.weapon == IT_PLASMA_GUN)
  1372.         {
  1373.             self.weapon = IT_AXE;
  1374.         }
  1375.         else if (self.weapon == IT_AXE)
  1376.         {
  1377. //ZOID--
  1378.             if (deathmatch && teamplay >= TEAM_CTF)
  1379.                 self.weapon = IT_GRAPPLE;
  1380.             else
  1381.             {
  1382.                 self.weapon = IT_SHOTGUN;
  1383.                 if (self.ammo_shells1 < 1)
  1384.                     am = 1;
  1385.             }
  1386. //--ZOID
  1387.         }
  1388.         else if (self.weapon == IT_GRAPPLE)
  1389.         {
  1390.             self.weapon = IT_SHOTGUN;
  1391.             if (self.ammo_shells1 < 1)
  1392.                 am = 1;
  1393.         }
  1394. //--ZOID
  1395.         else if (self.weapon == IT_SHOTGUN)
  1396.         {
  1397.             self.weapon = IT_SUPER_SHOTGUN;
  1398.             if (self.ammo_shells1 < 2)
  1399.                 am = 1;
  1400.         }        
  1401.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1402.         {
  1403.             self.weapon = IT_NAILGUN;
  1404.             if (self.ammo_nails1 < 1)
  1405.                 am = 1;
  1406.         }
  1407.         else if (self.weapon == IT_NAILGUN)
  1408.         {
  1409.             self.weapon = IT_LAVA_NAILGUN;
  1410.             if (self.ammo_lava_nails < 1)
  1411.                 am = 1;
  1412.         }
  1413.         else if (self.weapon == IT_LAVA_NAILGUN)
  1414.         {
  1415.             self.weapon = IT_SUPER_NAILGUN;
  1416.             if (self.ammo_nails1 < 2)
  1417.                 am = 1;
  1418.         }
  1419.         else if (self.weapon == IT_SUPER_NAILGUN)
  1420.         {
  1421.             self.weapon = IT_LAVA_SUPER_NAILGUN;
  1422.             if (self.ammo_lava_nails < 2)
  1423.                 am = 1;
  1424.         }
  1425.         else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1426.         {
  1427.             self.weapon = IT_GRENADE_LAUNCHER;
  1428.             if (self.ammo_rockets1 < 1)
  1429.                 am = 1;
  1430.         }
  1431.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1432.         {
  1433.             self.weapon = IT_MULTI_GRENADE;
  1434.             if (self.ammo_multi_rockets < 1)
  1435.                 am = 1;
  1436.         }
  1437.         else if (self.weapon == IT_MULTI_GRENADE)
  1438.         {
  1439.             self.weapon = IT_ROCKET_LAUNCHER;
  1440.             if (self.ammo_rockets1 < 1)
  1441.                 am = 1;
  1442.         }
  1443.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1444.         {
  1445.             self.weapon = IT_MULTI_ROCKET;
  1446.             if (self.ammo_multi_rockets < 1)
  1447.                 am = 1;
  1448.         }
  1449.         else if (self.weapon == IT_MULTI_ROCKET)
  1450.         {
  1451.             self.weapon = IT_LIGHTNING;
  1452.             if (self.ammo_cells1 < 1)
  1453.                 am = 1;
  1454.         }
  1455.         else if (self.weapon == IT_LIGHTNING)
  1456.         {
  1457.             self.weapon = IT_PLASMA_GUN;
  1458.             if (self.ammo_plasma < 1)
  1459.                 am = 1;
  1460.         }
  1461.  
  1462.         if ( (it & self.weapon) && am == 0)
  1463.         {
  1464.             W_SetCurrentAmmo ();
  1465.             return;
  1466.         }
  1467.     }
  1468.  
  1469. };
  1470.  
  1471. /*
  1472. ============
  1473. CycleWeaponReverseCommand
  1474.  
  1475. Go to the prev weapon with ammo
  1476. ============
  1477. */
  1478. void() CycleWeaponReverseCommand =
  1479. {
  1480.     local    float    it, am;
  1481.     
  1482.     EnableComboWeapons ( self );
  1483.     UpdateAmmoCounts ( self );
  1484.  
  1485.     it = self.items;
  1486.     self.impulse = 0;
  1487.  
  1488.     while (1)
  1489.     {
  1490.         am = 0;
  1491.  
  1492.         if (self.weapon == IT_PLASMA_GUN)
  1493.         {
  1494.             self.weapon = IT_LIGHTNING;
  1495.             if (self.ammo_cells1 < 1)
  1496.                 am = 1;
  1497.         }
  1498.         else if (self.weapon == IT_LIGHTNING)
  1499.         {
  1500.             self.weapon = IT_MULTI_ROCKET;
  1501.             if (self.ammo_multi_rockets < 1)
  1502.                 am = 1;
  1503.         }
  1504.         else if (self.weapon == IT_MULTI_ROCKET)
  1505.         {
  1506.             self.weapon = IT_ROCKET_LAUNCHER;
  1507.             if (self.ammo_rockets1 < 1)
  1508.                 am = 1;
  1509.         }
  1510.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1511.         {
  1512.             self.weapon = IT_MULTI_GRENADE;
  1513.             if (self.ammo_multi_rockets < 1)
  1514.                 am = 1;
  1515.         }
  1516.         else if (self.weapon == IT_MULTI_GRENADE)
  1517.         {
  1518.             self.weapon = IT_GRENADE_LAUNCHER;
  1519.             if (self.ammo_rockets1 < 1)
  1520.                 am = 1;
  1521.         }
  1522.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1523.         {
  1524.             self.weapon = IT_LAVA_SUPER_NAILGUN;
  1525.             if (self.ammo_lava_nails < 2)
  1526.                 am = 1;
  1527.         }
  1528.         else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1529.         {
  1530.             self.weapon = IT_SUPER_NAILGUN;
  1531.             if (self.ammo_nails1 < 2)
  1532.                 am = 1;
  1533.         }
  1534.         else if (self.weapon == IT_SUPER_NAILGUN)
  1535.         {
  1536.             self.weapon = IT_LAVA_NAILGUN;
  1537.             if (self.ammo_lava_nails < 2)
  1538.                 am = 1;
  1539.         }
  1540.         else if (self.weapon == IT_LAVA_NAILGUN)
  1541.         {
  1542.             self.weapon = IT_NAILGUN;
  1543.             if (self.ammo_nails1 < 1)
  1544.                 am = 1;
  1545.         }
  1546.         else if (self.weapon == IT_NAILGUN)
  1547.         {
  1548.             self.weapon = IT_SUPER_SHOTGUN;
  1549.             if (self.ammo_shells1 < 2)
  1550.                 am = 1;
  1551.         }        
  1552.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1553.         {
  1554.             self.weapon = IT_SHOTGUN;
  1555.             if (self.ammo_shells1 < 1)
  1556.                 am = 1;
  1557.         }
  1558.         else if (self.weapon == IT_SHOTGUN)
  1559.         {
  1560. //PGM
  1561.             if (deathmatch && teamplay >= TEAM_CTF)
  1562.                 self.weapon = IT_GRAPPLE;
  1563.             else
  1564.                 self.weapon = IT_AXE;
  1565. //PGM
  1566.         }
  1567. //ZOID--
  1568.         else if (self.weapon == IT_GRAPPLE) 
  1569.         {
  1570.             self.weapon = IT_AXE;
  1571.         }
  1572. //--ZOID
  1573.         else if (self.weapon == IT_AXE)
  1574.         {
  1575.             self.weapon = IT_PLASMA_GUN;
  1576.             if (self.ammo_plasma < 1)
  1577.                 am = 1;
  1578.         }
  1579.     
  1580.         if ( (it & self.weapon) && am == 0)
  1581.         {
  1582.             W_SetCurrentAmmo ();
  1583.             return;
  1584.         }
  1585.     }
  1586.  
  1587. };
  1588.  
  1589. /*
  1590. ============
  1591. ServerflagsCommand
  1592.  
  1593. Just for development
  1594. ============
  1595. */
  1596. void() ServerflagsCommand =
  1597. {
  1598.     serverflags = serverflags * 2 + 1;
  1599. };
  1600.  
  1601. void() QuadCheat =
  1602. {
  1603.     if (deathmatch || coop)
  1604.         return;
  1605.     self.super_time = 1;
  1606.     self.super_damage_finished = time + 30;
  1607.     self.items = self.items | IT_QUAD;
  1608.     dprint ("quad cheat\n");
  1609. };
  1610.  
  1611.  
  1612. /*
  1613. ============
  1614. ImpulseCommands
  1615.  
  1616. ============
  1617. */
  1618. void() ImpulseCommands =
  1619. {
  1620.     local entity takeThisOut;
  1621.  
  1622.     if (self.impulse >= 1 && self.impulse <= 8)
  1623.         W_ChangeWeapon ();
  1624.     else if (self.impulse >= 60 && self.impulse <= 64)
  1625.         W_ChangeWeapon ();
  1626.     else if (self.impulse == 9)
  1627.         CheatCommand ();
  1628.     else if (self.impulse == 10)
  1629.         CycleWeaponCommand ();
  1630.     else if (self.impulse == 11)
  1631.         ServerflagsCommand ();
  1632.     else if (self.impulse == 12)
  1633.         CycleWeaponReverseCommand ();
  1634. //ZOID--
  1635. //teamplay stuff
  1636.     else if (self.impulse == 20)
  1637.         TossBackpack();
  1638.     else if (self.impulse == 21)
  1639.         TossWeapon();
  1640.     else if (self.impulse == 22)
  1641.     {
  1642.         if (deathmatch && teamplay >= TEAM_CTF)
  1643.             W_ChangeWeapon();
  1644.     }
  1645.     else if (self.impulse == 23)
  1646.         TeamFlagStatusReport();
  1647. //--ZOID
  1648.  
  1649.  
  1650.     // ### chasecam mod ###
  1651.     else if (self.impulse == 30) Toggle_chase_cam();
  1652.     else if (self.impulse == 31) LaserTargeterToggle( self );
  1653.  
  1654.     else if (self.impulse == 32) Chase_cam_change_zmult(0); // minus
  1655.     else if (self.impulse == 33) Chase_cam_change_zmult(1); // plus
  1656.     else if (self.impulse == 34) Chase_cam_change_dist(0); // minus
  1657.     else if (self.impulse == 35) Chase_cam_change_dist(1); // plus
  1658.  
  1659.     else if (self.impulse == 38) Chase_cam_read_temp1(0); // read cvar temp1 into player.dest2_y (cam distance)
  1660.     else if (self.impulse == 39) Chase_cam_read_temp1(1); // read cvar temp1 into player.dest2_z (cam height)
  1661.  
  1662.     // ### hot key weapon mod ###
  1663.     else if (self.impulse == 40) HotKey_previous_weapon();
  1664.     else if (self.impulse == 41) HotKey_weapon(1); // axe
  1665.     else if (self.impulse == 42) HotKey_weapon(2); // grenade
  1666.     else if (self.impulse == 43) HotKey_weapon(3); // rocket
  1667.     else if (self.impulse == 44) HotKey_CycleWeaponReverseCommand();
  1668.     else if (self.impulse == 45) HotKey_CycleWeaponCommand();
  1669.  
  1670.     // ### HUD mod ###
  1671.     else if (self.impulse == 50)
  1672.     {    // once player selects, turned on until full client reset
  1673.         if (! (self.dest2_x & HUD_ON) )
  1674.             self.dest2_x = self.dest2_x | HUD_ON;
  1675.         HUD_print_info(1);
  1676.     }
  1677.     // ### Swinging hook mod ###
  1678.     else if (self.impulse >= 95 && self.impulse <= 98)
  1679.         CheckGrapHook ();
  1680.     // ### Multiskin Pro mod ###
  1681.     else if (self.impulse == 200) Choose_multiskin(1);
  1682.     else if (self.impulse == 201) Choose_multiskin(0);
  1683.  
  1684.     // Rob; testing
  1685.     else if (self.impulse == 253)
  1686.     {  if (self.health > 1)
  1687.             self.health = self.health - 1;
  1688.     }
  1689.     else if (self.impulse == 254)
  1690.         self.health = self.health + 1;
  1691.  
  1692.  
  1693.     else if (self.impulse == 255)
  1694.         QuadCheat ();
  1695.  
  1696.     self.impulse = 0;
  1697. };
  1698.  
  1699. /*
  1700. ============
  1701. W_WeaponFrame
  1702.  
  1703. Called every frame so impulse events can be handled as well as possible
  1704. ============
  1705. */
  1706. void() W_WeaponFrame =
  1707. {
  1708.     // ### chasecam mod ###
  1709.  
  1710.     if (self.dest1_x != self.health)
  1711.         HUD_print_info(0);
  1712.  
  1713.     if (self.button2)
  1714.         CheckGrapHookJump ();
  1715.  
  1716.     if (time < self.attack_finished)
  1717.         return;
  1718.  
  1719.     if (lavaGunFired)
  1720.     {
  1721.         if (self.weapon == IT_LAVA_NAILGUN ||
  1722.             self.weapon == IT_LAVA_SUPER_NAILGUN)
  1723.         {
  1724.             sound (self, CHAN_WEAPON, "lavagun/snail.wav", 1, ATTN_NORM);
  1725.         }
  1726.         lavaGunFired = 0;
  1727.     }
  1728.  
  1729.     if (self.impulse)
  1730.         ImpulseCommands ();
  1731.  
  1732. // check for attack
  1733.     if (self.button0)
  1734.     {
  1735.         SuperDamageSound ();
  1736.         W_Attack ();
  1737.     }
  1738. };
  1739.  
  1740. /*
  1741. ========
  1742. SuperDamageSound
  1743.  
  1744. Plays sound if needed
  1745. ========
  1746. */
  1747. void() SuperDamageSound =
  1748. {
  1749.     if (self.super_damage_finished > time)
  1750.     {
  1751.         if (self.super_sound < time)
  1752.         {
  1753.             self.super_sound = time + 1;
  1754.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1755.         }
  1756.     }
  1757.     return;
  1758. };
  1759.  
  1760.  
  1761.